package com.ruoyi.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.domain.ErpPurchaseInventory;
import com.ruoyi.service.IErpPurchaseInventoryService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 采购入库Controller
 * 
 * @author ruoyi
 * @date 2025-07-17
 */
@RestController
@RequestMapping("/ruku/rukus")
public class ErpPurchaseInventoryController extends BaseController
{
    @Autowired
    private IErpPurchaseInventoryService erpPurchaseInventoryService;

    /**
     * 查询采购入库列表
     */
    @PreAuthorize("@ss.hasPermi('ruku:rukus:list')")
    @GetMapping("/list")
    public TableDataInfo list(ErpPurchaseInventory erpPurchaseInventory)
    {
        startPage();
        List<ErpPurchaseInventory> list = erpPurchaseInventoryService.selectErpPurchaseInventoryList(erpPurchaseInventory);
        return getDataTable(list);
    }

    /**
     * 导出采购入库列表
     */
    @PreAuthorize("@ss.hasPermi('ruku:rukus:export')")
    @Log(title = "采购入库", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ErpPurchaseInventory erpPurchaseInventory)
    {
        List<ErpPurchaseInventory> list = erpPurchaseInventoryService.selectErpPurchaseInventoryList(erpPurchaseInventory);
        ExcelUtil<ErpPurchaseInventory> util = new ExcelUtil<ErpPurchaseInventory>(ErpPurchaseInventory.class);
        util.exportExcel(response, list, "采购入库数据");
    }

    /**
     * 获取采购入库详细信息
     */
    @PreAuthorize("@ss.hasPermi('ruku:rukus:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(erpPurchaseInventoryService.selectErpPurchaseInventoryById(id));
    }

    /**
     * 新增采购入库
     */
    @PreAuthorize("@ss.hasPermi('ruku:rukus:add')")
    @Log(title = "采购入库", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ErpPurchaseInventory erpPurchaseInventory)
    {
        return toAjax(erpPurchaseInventoryService.insertErpPurchaseInventory(erpPurchaseInventory));
    }

    /**
     * 修改采购入库
     */
    @PreAuthorize("@ss.hasPermi('ruku:rukus:edit')")
    @Log(title = "采购入库", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ErpPurchaseInventory erpPurchaseInventory)
    {
        return toAjax(erpPurchaseInventoryService.updateErpPurchaseInventory(erpPurchaseInventory));
    }

    /**
     * 删除采购入库
     */
    @PreAuthorize("@ss.hasPermi('ruku:rukus:remove')")
    @Log(title = "采购入库", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(erpPurchaseInventoryService.deleteErpPurchaseInventoryByIds(ids));
    }
}
